package sy.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import sy.dao.AppRepairDaoI;
import sy.model.AppRepair;
@Repository("appRepairDao")
public class AppRepairDaoImpl implements AppRepairDaoI{
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	private Session getCurrentSession(){
		return this.getSessionFactory().getCurrentSession();
	}

	@Override
	public Serializable save(AppRepair appRepair) {
		// TODO Auto-generated method stub
		return this.getCurrentSession().save(appRepair);
	}

	@Override
	public List<AppRepair> list() {
		// TODO Auto-generated method stub
		return this.getCurrentSession().createQuery("from AppRepair").list();
	}
	
}
